package com.mycjj.android.activity;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.mycjj.android.R;
import com.mycjj.android.util.Preferences;

public class TiXingActivity extends BaseActivity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_me_tixing);
		init();
	}
	
	private ImageView mHeaderLeftImageview;
	private Button mHeaderRightButton;
	private TextView mHeaderTitleTextView;
	private void initHeader(){
		mHeaderLeftImageview = (ImageView) findViewById(R.id.header_left_button);
		mHeaderLeftImageview.setImageResource(R.drawable.back);
		mHeaderRightButton = (Button) findViewById(R.id.header_right_button);
		mHeaderRightButton.setVisibility(View.GONE);
		mHeaderTitleTextView = (TextView) findViewById(R.id.header_title_textview);
		mHeaderTitleTextView.setText("提醒");
		mHeaderLeftImageview.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				TiXingActivity.this.finish();
			}
		});
	}
	
	private View ll_item2,ll_item3;
	private View rl_item1_01;
	private TextView tv_xh_time,tv_gs_name,tv_baoxian_time,tv_year_end_date;
	private void init(){
		initHeader();
		ll_item2 = findViewById(R.id.ll_item2);
		ll_item3 = findViewById(R.id.ll_item3);
		rl_item1_01 = findViewById(R.id.rl_item1_01);
		rl_item1_01.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				Intent intent = new Intent(TiXingActivity.this,My_MessageListActivity.class);
				dataManager.setNo_read_count(0);
				startActivity(intent);
			}
		});
		
		tv_xh_time = (TextView) findViewById(R.id.tv_xh_time);
		tv_gs_name = (TextView) findViewById(R.id.tv_gs_name);
		tv_baoxian_time = (TextView) findViewById(R.id.tv_baoxian_time);
		tv_year_end_date = (TextView) findViewById(R.id.tv_year_end_date);
		
		
		
		//保险公司名称
		String gsName = Preferences.getSharedPreferences(mApp, "msg_gs_name", "");
		if(TextUtils.isEmpty(gsName)){
			ll_item2.setVisibility(View.GONE);
		}else{
			tv_gs_name.setText(gsName);
			//保险到期日
			String baoxianTime = Preferences.getSharedPreferences(mApp, "msg_gs_end_time", "暂未获取");
			tv_baoxian_time.setText("保险到期日:"+baoxianTime);
			ll_item2.setVisibility(View.VISIBLE);
		}
		
		String yearCheckTime = Preferences.getSharedPreferences(mApp, "msg_year_check_time", "");
		if(TextUtils.isEmpty(yearCheckTime)){
			ll_item3.setVisibility(View.GONE);
		}else{
			tv_year_end_date.setText("年检到期日 :"+yearCheckTime);
			ll_item3.setVisibility(View.VISIBLE);
		}
	}
	
	@Override
	protected void onResume() {
		super.onResume();
		int msgCount = dataManager.getNo_read_count();
		tv_xh_time.setText(msgCount+"条未读消息");
	}
	
	

}
